[HVM][VMX] Move hvm interface init_hypercall_page initialization into vmx_setup_hvm_f...
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Tue, 8 Aug 2006 08:59:47 +0000 (09:59 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Tue, 8 Aug 2006 08:59:47 +0000 (09:59 +0100)
Signed-off-by: Xin Li <xin.b.li@intel.com>
xen/arch/x86/hvm/vmx/vmx.c

index 7f5439ddf702bb2d62b6816f4b5455c62483953a..a7079d8b41469d6b737c00a451761777d5d7dada 100644 (file)
@@ -671,6 +671,28 @@ static int check_vmx_controls(u32 ctrls, u32 msr)
     return 1;
 }
 
+static void vmx_init_hypercall_page(struct domain *d, void *hypercall_page)
+{
+    char *p;
+    int i;
+
+    memset(hypercall_page, 0, PAGE_SIZE);
+
+    for ( i = 0; i < (PAGE_SIZE / 32); i++ )
+    {
+        p = (char *)(hypercall_page + (i * 32));
+        *(u8  *)(p + 0) = 0xb8; /* mov imm32, %eax */
+        *(u32 *)(p + 1) = i;
+        *(u8  *)(p + 5) = 0x0f; /* vmcall */
+        *(u8  *)(p + 6) = 0x01;
+        *(u8  *)(p + 7) = 0xc1;
+        *(u8  *)(p + 8) = 0xc3; /* ret */
+    }
+
+    /* Don't support HYPERVISOR_iret at the moment */
+    *(u16 *)(hypercall_page + (__HYPERVISOR_iret * 32)) = 0x0b0f; /* ud2 */
+}
+
 /* Setup HVM interfaces */
 static void vmx_setup_hvm_funcs(void)
 {
@@ -691,28 +713,8 @@ static void vmx_setup_hvm_funcs(void)
     hvm_funcs.get_guest_ctrl_reg = vmx_get_ctrl_reg;
 
     hvm_funcs.init_ap_context = vmx_init_ap_context;
-}
 
-static void vmx_init_hypercall_page(struct domain *d, void *hypercall_page)
-{
-    char *p;
-    int i;
-
-    memset(hypercall_page, 0, PAGE_SIZE);
-
-    for ( i = 0; i < (PAGE_SIZE / 32); i++ )
-    {
-        p = (char *)(hypercall_page + (i * 32));
-        *(u8  *)(p + 0) = 0xb8; /* mov imm32, %eax */
-        *(u32 *)(p + 1) = i;
-        *(u8  *)(p + 5) = 0x0f; /* vmcall */
-        *(u8  *)(p + 6) = 0x01;
-        *(u8  *)(p + 7) = 0xc1;
-        *(u8  *)(p + 8) = 0xc3; /* ret */
-    }
-
-    /* Don't support HYPERVISOR_iret at the moment */
-    *(u16 *)(hypercall_page + (__HYPERVISOR_iret * 32)) = 0x0b0f; /* ud2 */
+    hvm_funcs.init_hypercall_page = vmx_init_hypercall_page;
 }
 
 int start_vmx(void)
@@ -781,8 +783,6 @@ int start_vmx(void)
 
     vmx_setup_hvm_funcs();
 
-    hvm_funcs.init_hypercall_page = vmx_init_hypercall_page;
-
     hvm_enabled = 1;
 
     return 1;